/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ReportesRSC_UI.java
 *
 * Created on 27/06/2009, 08:06:03 PM
 */

package CRM_UI;

import DAO.DAOCasoServicioCliente;
import DAO.DAOCsc_Accion;
import java.util.Vector;

/**
 *
 * @author L¡z
 */
public class ReportesRSC_UI extends javax.swing.JFrame {

    /** Creates new form ReportesRSC_UI */
    Vector <Vector> csc = new Vector <Vector> ();
    Vector <String> cscComboBox = new Vector <String> ();
    String idEmpleado = "";

    public ReportesRSC_UI(String idEmpleado)
    {
        this.idEmpleado = idEmpleado;
        inicializarComboBox();
        initComponents();
        setLocationRelativeTo(null);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        reportesButtonGroup = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        trazabilidadRadioButton = new javax.swing.JRadioButton();
        pendientesRadioButton = new javax.swing.JRadioButton();
        cbCsc = new javax.swing.JComboBox(cscComboBox);
        generarButton = new javax.swing.JButton();

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder("Reportes"))));

        jLabel1.setText("Seleccione el reporte que desea generar:");

        reportesButtonGroup.add(trazabilidadRadioButton);
        trazabilidadRadioButton.setText("Trazabilidad de un Caso de Servicio al Cliente");
        trazabilidadRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                trazabilidadRadioButtonActionPerformed(evt);
            }
        });

        reportesButtonGroup.add(pendientesRadioButton);
        pendientesRadioButton.setText("Casos Pendientes por Solucionar");

        /*
        */

        generarButton.setText("generar");
        generarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                generarButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(trazabilidadRadioButton)
                            .addComponent(pendientesRadioButton)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(40, 40, 40)
                        .addComponent(cbCsc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(178, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(201, Short.MAX_VALUE)
                .addComponent(generarButton)
                .addGap(168, 168, 168))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(trazabilidadRadioButton)
                .addGap(17, 17, 17)
                .addComponent(cbCsc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(pendientesRadioButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
                .addComponent(generarButton))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(25, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public void inicializarComboBox()
    {
        DAOCasoServicioCliente daoCSC = new DAOCasoServicioCliente();
        csc = daoCSC.descripcionCSC();
        System.out.println(csc.size());
        System.out.println(csc.elementAt(0).size());

        for(int i=0; i<csc.size(); i++)
        {
            String id = csc.elementAt(i).elementAt(0).toString();
            //String descripcion = csc.elementAt(i).elementAt(1).toString();
            cscComboBox.addElement(id);
        }
    }

    public Vector <String> columnasTrazabilidad()
    {
        Vector <String> columnas = new Vector <String> ();
        columnas.addElement("Identificación CSC");
        columnas.addElement("Descripción");
        columnas.addElement("Fecha Inicio");
        columnas.addElement("Fecha Finalización");
        columnas.addElement("Identificación Acción");
        columnas.addElement("Descripción Acción");
        columnas.addElement("Fecha Acción");

        return columnas;
    }

    public Vector <String> columnasCSCPendientes()
    {
        Vector <String> columnas = new Vector <String> ();
        columnas.addElement("Identificación CSC");
        columnas.addElement("Estado");
        columnas.addElement("Nivel de Prioridad");
        columnas.addElement("Tipo");
        columnas.addElement("Descripción");
        columnas.addElement("Fecha Inicio");
        columnas.addElement("Fecha Finalización");
        columnas.addElement("Identificación Cliente");
        columnas.addElement("Nombre Cliente");

        return columnas;
    }

    private void trazabilidadRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_trazabilidadRadioButtonActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_trazabilidadRadioButtonActionPerformed

    private void generarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generarButtonActionPerformed
        // TODO add your handling code here:
        if( trazabilidadRadioButton.isSelected() )
        {
            int index = cbCsc.getSelectedIndex();
            String idCSC = csc.elementAt(index).elementAt(0).toString();

            DAOCsc_Accion objDaoCSCAccion = new DAOCsc_Accion();
            Vector <Vector> trazabilidad = objDaoCSCAccion.consultarTrazabilidad(idCSC);

            Vector <String> nombreColumnas = columnasTrazabilidad();
            TablaReportesUI objTablaReportesUI = new TablaReportesUI(trazabilidad, nombreColumnas,"");
            objTablaReportesUI.setVisible(true);
        }
        if( pendientesRadioButton.isSelected() )
        {
            DAOCasoServicioCliente objDaoCSC = new DAOCasoServicioCliente();
            Vector <Vector> pendientes = objDaoCSC.casosPendientes(idEmpleado);

            Vector <String> nombreColumnas = columnasCSCPendientes();
            TablaReportesUI objTablaReportesUI = new TablaReportesUI(pendientes, nombreColumnas, "");
            objTablaReportesUI.setVisible(true);
        }
    }//GEN-LAST:event_generarButtonActionPerformed

    /**
    * @param args the command line arguments
    */
    /*
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ReportesRSC_UI().setVisible(true);
            }
        });
    }
     * */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cbCsc;
    private javax.swing.JButton generarButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton pendientesRadioButton;
    private javax.swing.ButtonGroup reportesButtonGroup;
    private javax.swing.JRadioButton trazabilidadRadioButton;
    // End of variables declaration//GEN-END:variables

}
